import { Component, ViewChild } from '@angular/core';
import { Events, Nav, Platform } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Storage } from '@ionic/storage';
import { ConferenceData } from '../providers/conference-data';


@Component({ 
  templateUrl: 'app.template.html'
})
export class YIonicApp {
  // the root nav is a child of the root app component
  // @ViewChild(Nav) gets a reference to the app's root nav
  @ViewChild(Nav) nav: Nav;
  rootPage: any;

  constructor(
    public events: Events,
    public platform: Platform,
    public confData: ConferenceData,
    public storage: Storage,
    public splashScreen: SplashScreen,
  ) {

    // Check if the user has already seen the tutorial
    let token = localStorage.getItem('token');
    if (token) {
      console.log((new Date().getTime()/1000).toFixed(0));
      console.log("登录成功了有token了:"+token);
      console.log("登录成功了有token了"+JSON.parse(token).access_token);
      this.rootPage = 'TabsPage';
    } else {
      console.log("未登录，滚到登录界面去")
      this.rootPage = 'LoginPage';
    }
    // this.platformReady()
    // load the conference data
    // confData.load();
  }

  // platformReady() {
  //   // Call any initial plugins when ready
  //   this.platform.ready().then(() => {
  //     this.splashScreen.hide();
  //   });
  // }
}
